package Thread;

/**
 * 获取线程相关信息的方法
 */
public class ThreadinfoDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();//获取主线程

        String name = main.getName();//获取线程名
        System.out.println("线程名"+name);

        long id = main.getId();//获取唯一标识(非空且唯一)
        System.out.println("唯一标识"+id);

        int priority = main.getPriority();//获取线程优先级
        System.out.println("优先级"+priority);

        boolean isLive = main.isAlive();//判断线程状态
        System.out.println("是否存活"+isLive);

        boolean isDamon = main.isDaemon();//是否守护线程
        System.out.println("是否守护线程"+isDamon);

        boolean isInterrupted = main.isInterrupted();//是否中断
        System.out.println("是否中断"+isInterrupted);
    }
}
